//
//  NSString+ImageUrl.m
//  ANG
//
//  Created by fuxiang on 15/10/22.
//  Copyright (c) 2015年 aniuge. All rights reserved.
//

#import "NSString+ImageUrl.h"

//是否为空或是[NSNull null]
#define NotNilAndNull(_ref)  (((_ref) != nil) && (![(_ref) isEqual:[NSNull null]]) && (![(_ref) isEqual:@"null"]) && (![(_ref) isEqual:@"(null)"]))

#define IsNilOrNull(_ref)   (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) || ([(_ref) isEqual:@"null"]) || ([(_ref) isEqual:@"(null)"]))

//数组是否为空
#define IsArrEmpty(_ref)    (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) ||([(_ref) count] == 0))

@implementation NSString (ImageUrl)

+ (NSString *)stringWithImageUrl:(NSString *)imageUrl imageWidth:(NSInteger)imageWidth imageHeight:(NSInteger)imageHeight
{
    
    if (NotNilAndNull(imageUrl) && !IsStrEmpty(imageUrl))
    {
        NSString *imageSizeStr = [NSString stringWithFormat:@"_%ld_%ld",(long)imageWidth,(long)imageHeight];
        
        NSMutableString *imageStr = [[NSMutableString alloc] initWithFormat:@"%@", imageUrl];
        [imageStr insertString:imageSizeStr atIndex:imageStr.length-4];
        
        return imageStr;
    }
    return @"";
}

@end
